home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume25 / fromwho < prev    next >
Encoding:
Internet Message Format  |  1991-12-13  |  20.1 KB

  1. Subject: v25i028: fromwho - yet another replacement for from(1)
  2. Newsgroups: comp.sources.unix
  3. Approved: vixie@pa.dec.com
  4.  
  5. Submitted-By: jearls@blackbird.csc.calpoly.edu
  6. Posting-Number: Volume 25, Issue 28
  7. Archive-Name: fromwho
  8.  
  9. This is a new 'from' program.  Instead of just listing who your mail is
  10. from, it tells you how many total messages, how many are new, and
  11. for each person you have mail from, tells how many messages they sent,
  12. how many are new, and lists the subjects of the messages.
  13.  
  14. [ This program requires an ANSI-compliant C compiler to build.  --Nick ]
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then unpack
  18. # it by saving it into a file and typing "sh file".  To overwrite existing
  19. # files, type "sh file -c".  You can also feed this as standard input via
  20. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  21. # will see the following message at the end:
  22. #        "End of archive 1 (of 1)."
  23. # Contents:  CHANGES INSTALL MANIFEST Makefile README fromwho.c
  24. #   fromwho.man patchlevel.h
  25. # Wrapped by jearls@phantom on Tue Dec  3 11:17:07 1991
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f 'CHANGES' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'CHANGES'\"
  29. else
  30. echo shar: Extracting \"'CHANGES'\" \(409 characters\)
  31. sed "s/^X//" >'CHANGES' <<'END_OF_FILE'
  32. XRevision 1.3  91/12/03  11:14:15  jearls
  33. XPATCH3: Added `-v' option to display the version number.
  34. X
  35. XRevision 1.2  91/11/23  12:49:40  jearls
  36. XPATCH2: Fixed miscellanous bugs, added '-n' option to
  37. XPATCH2: list only new mail.
  38. X
  39. XRevision 1.1  91/10/19  17:06:12  jearls
  40. XPATCH1: Added support for AIX and other systems that don't
  41. XPATCH1: use a mail spool.
  42. X
  43. XRevision 1.0  91/10/19  14:40:25  jearls
  44. XInitial revision
  45. X
  46. END_OF_FILE
  47. if test 409 -ne `wc -c <'CHANGES'`; then
  48.     echo shar: \"'CHANGES'\" unpacked with wrong size!
  49. fi
  50. # end of 'CHANGES'
  51. fi
  52. if test -f 'INSTALL' -a "${1}" != "-c" ; then 
  53.   echo shar: Will not clobber existing file \"'INSTALL'\"
  54. else
  55. echo shar: Extracting \"'INSTALL'\" \(2860 characters\)
  56. sed "s/^X//" >'INSTALL' <<'END_OF_FILE'
  57. XInstallation instructions for fromwho:
  58. X
  59. X
  60. XUpdating the `Tweakables' section of the Makefile:
  61. X
  62. X  There are seven parameters in the Makefile that affect
  63. X  the installation of fromwho:
  64. X
  65. X    CC        This is the C compiler you will compile
  66. X        with.  It must be ANSI-C compliant.
  67. X
  68. X    CCFLAGS    What default flags to send to the C
  69. X        compiler.  On some systems you may need
  70. X        to add '-Dindex=strchr' to this line.
  71. X
  72. X    MAIL    How to find the incoming mailbox for a
  73. X        user.  If this is left blank, then the
  74. X        incoming mailbox will be
  75. X
  76. X            /usr/spool/mail/<username>
  77. X
  78. X        If incoming mail is kept in a different
  79. X        directory "/xyz/<username>", then
  80. X        set MAIL to
  81. X
  82. X            -DMAILDIR=\"/xyz/\"
  83. X
  84. X        If incoming mail is set up in some other
  85. X        fashion (i.e. all mailboxes not in the
  86. X        same directory) then set MAIL to
  87. X
  88. X            -DMAILFILE=\"<mailbox>\"
  89. X
  90. X        where <mailbox> is the path to the mail-
  91. X        box file.  <mailbox> may contain a ~ for
  92. X        the user's home directory and a * for the
  93. X        user's login name.  For example, AIX keeps
  94. X        it's incoming mail in the file `.newmail'
  95. X        in the user's home directory.  For this
  96. X        setup, MAIL would be defined as
  97. X
  98. X            -DMAILFILE=\"~/.newmail\"
  99. X
  100. X    STRIP    If you want the executable stripped after
  101. X        being compiled, set this to `strip', other-
  102. X        wise, set it to `touch'.
  103. X
  104. X    SECTION    The section of the manual to install as.
  105. X        Normally either `1' (one), `l', or `n'.
  106. X
  107. X    BIN        The directory to install the executable
  108. X        in.
  109. X    MAN        The directory to install the manpage in.
  110. X           (The manpage will actaully be instaled
  111. X        one level below this, in a directory called
  112. X        manX, where X is the SECTION defined above)
  113. X
  114. X  After setting up these parameters, build the executable
  115. X  and manpage with `make' with no parameters.  If there are
  116. X  any problems in compiling, send mail to the address given
  117. X  at the end of this file describing the errors and the
  118. X  system you're trying to install on, and be prepared to
  119. X  send a script of the `make' (but don't do this until I ask
  120. X  for it :)
  121. X
  122. X  If the executable builds correctly, test it out by running
  123. X  `make verify'.  It will run through the various test mail-
  124. X  boxes to insure that the parameters work correctly and
  125. X  that it is reading the mailboxes correctly.  It will also
  126. X  create a shell script to attempt to verify that the MAIL
  127. X  setting is correct.
  128. X
  129. X  When you are satisfied that it works correctly, type `make
  130. X  info' to check that the directories are correct, and `make
  131. X  install'.  If the directories aren't correct, modify the
  132. X  Makefile and re-make.
  133. X
  134. XIf you have any problems compiling or installing fromwho,
  135. Xmail a description of the problems encountered and a
  136. Xdescription of the system on which you are trying to
  137. Xinstall to:
  138. X
  139. X    jearls@blackbird.csc.calpoly.edu
  140. X
  141. XBe prepared to send a script of the `make' process -- but
  142. Xnot until I ask you for it.  :)
  143. X
  144. XSuggestions and comments are also welcome.
  145. END_OF_FILE
  146. if test 2860 -ne `wc -c <'INSTALL'`; then
  147.     echo shar: \"'INSTALL'\" unpacked with wrong size!
  148. fi
  149. # end of 'INSTALL'
  150. fi
  151. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  152.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  153. else
  154. echo shar: Extracting \"'MANIFEST'\" \(507 characters\)
  155. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  156. X   File Name        Archive #    Description
  157. X-----------------------------------------------------------
  158. X CHANGES                    1    Changes since v1.0
  159. X INSTALL                    1    Installation instructions
  160. X MANIFEST                   1    This file
  161. X Makefile                   1    Build file for 'make'
  162. X README                     1    Description of fromwho
  163. X fromwho.c                  1    The program source.
  164. X fromwho.man                1    Template for the manpage.
  165. X patchlevel.h               1    The current patch level.
  166. END_OF_FILE
  167. if test 507 -ne `wc -c <'MANIFEST'`; then
  168.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  169. fi
  170. # end of 'MANIFEST'
  171. fi
  172. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  173.   echo shar: Will not clobber existing file \"'Makefile'\"
  174. else
  175. echo shar: Extracting \"'Makefile'\" \(2304 characters\)
  176. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  177. X#
  178. X# Makefile for $(PROG)
  179. X#
  180. X# (See INSTALL file for installation instructions)
  181. X#
  182. X# Tweakables:
  183. X#
  184. X
  185. X# Your CC must grok ANSI C
  186. XCC =        gcc
  187. X#CC =        cc
  188. X
  189. XCCFLAGS =    -O
  190. X#CCFLAGS =    -g
  191. X
  192. XMAIL =
  193. X#MAIL = -DMAILDIR=\"/usr/mail/\"
  194. X#MAIL = -DMAILFILE=\"~/.newmail\"
  195. X
  196. XSTRIP =        strip
  197. X#STRIP =    touch    # use if you don't want the
  198. X#            # executable strip'd
  199. X
  200. XSECTION =    n
  201. X
  202. XBIN =        /usr/local/bin
  203. XMAN =        /usr/local/man
  204. X
  205. X########### Don't change anything below this line ##########
  206. X
  207. XPROG =        fromwho
  208. XOBJS =        fromwho.o
  209. XSRCS =        fromwho.c patchlevel.h
  210. XMANPAGE =    $(PROG).$(SECTION)
  211. XMANDIR =    $(MAN)/man$(SECTION)
  212. XCFLAGS =    $(CCFLAGS) $(MAIL)
  213. X
  214. Xall:        $(PROG) $(MANPAGE)
  215. X
  216. X$(PROG):    $(OBJS)
  217. X        $(CC) $(CFLAGS) -o $(PROG) $(OBJS) \
  218. X            $(LDFLAGS) $(LIBS)
  219. X        $(STRIP) $(PROG)
  220. X
  221. X$(MANPAGE):    $(PROG).man sedscript
  222. X        ./sedscript < $(PROG).man > $(MANPAGE)
  223. X
  224. Xinfo:
  225. X        @echo
  226. X        @echo '`'"make install' will install" \
  227. X            "$(PROG) into $(BIN)"
  228. X        @echo "and $(MANPAGE) into $(MANDIR)."
  229. X        @echo
  230. X
  231. Xinstall:    $(PROG) $(MANPAGE)
  232. X        -if test ! -d $(BIN) ; then mkdir $(BIN) ; fi
  233. X        -if test -r $(BIN)/$(PROG) ; then rm -f $(BIN)/$(PROG).old ; mv $(BIN)/$(PROG) $(BIN)/$(PROG).old ; fi
  234. X        cp $(PROG) $(BIN)/$(PROG)
  235. X        -if test ! -d $(MAN) ; then mkdir $(MAN) ; fi
  236. X        -if test ! -d $(MANDIR) ; then mkdir $(MANDIR) ; fi
  237. X        -if test -r $(MANDIR)/$(MANPAGE) ; then rm -f $(MANDIR)/$(MANPAGE).old ; mv $(MANDIR)/$(MANPAGE) $(MANDIR)/$(MANPAGE).old ; fi
  238. X        cp $(MANPAGE) $(MANDIR)/$(MANPAGE)
  239. X
  240. Xsedscript:    Makefile
  241. X        @rm -f sedscript
  242. X        @echo "#!/bin/sh" > sedscript
  243. X        @echo 'set `date`' >> sedscript
  244. X        @echo 'DATE="$$3 $$2 $$6"' >> sedscript
  245. X        @echo 'set '"'"'"'"'"'`grep "Revision" patchlevel.h`'"'"'"'"'" >> sedscript
  246. X        @echo 'VERSION="$$3"' >> sedscript
  247. X        @echo 'sed "s/%V%/$$VERSION/g" | sed "s/%D%/$$DATE/g" | sed "s/%S%/$(SECTION)/g"' >> sedscript
  248. X        @chmod 700 sedscript
  249. X
  250. Xclean:
  251. X        rm -f *.o $(PROG) $(MANPAGE) sedscript
  252. X
  253. Xverify:        $(PROG)
  254. X
  255. X############################################################
  256. X#
  257. X# The following are what I use to make a distribution.  They
  258. X# probably won't be very helpful to you.
  259. X#
  260. X############################################################
  261. X
  262. Xpackage:    $(SRCS) $(PROG).man Makefile MANIFEST CHANGES README INSTALL
  263. X        @echo "Creating package..."
  264. X        makekit -m
  265. X
  266. XCHANGES:    $(SRCS)
  267. X        sed '1,/$$Log:/d' patchlevel.h | sed '/\*\//,$$d' | sed 's/^....//' > CHANGES
  268. END_OF_FILE
  269. if test 2304 -ne `wc -c <'Makefile'`; then
  270.     echo shar: \"'Makefile'\" unpacked with wrong size!
  271. fi
  272. # end of 'Makefile'
  273. fi
  274. if test -f 'README' -a "${1}" != "-c" ; then 
  275.   echo shar: Will not clobber existing file \"'README'\"
  276. else
  277. echo shar: Extracting \"'README'\" \(693 characters\)
  278. sed "s/^X//" >'README' <<'END_OF_FILE'
  279. X  fromwho -- 'from' with extras
  280. X
  281. X  This is a new 'from' program.  Instead of just listing who your mail is
  282. X  from, it tells you how many total messages, how many are new, and
  283. X  for each person you have mail from, tells how many messages they sent,
  284. X  how many are new, and lists the subjects of the messages.
  285. X
  286. X  This code is public domain.  I might keep updating it, or I might forget
  287. X  about it ]:)  But feel free to mail comments / suggestions to me at
  288. X    jearls@data.acs.calpoly.edu
  289. X
  290. X  Usage:
  291. X    fromwho [-l] [-s] [-n] [-f [<mailbox>]]
  292. X
  293. X    -f  Sets the mailbox to read from.
  294. X    -l  Turns listing of users/subjects off.
  295. X    -n  Lists only new mail.
  296. X    -s  Turns listing of subjects off.
  297. END_OF_FILE
  298. if test 693 -ne `wc -c <'README'`; then
  299.     echo shar: \"'README'\" unpacked with wrong size!
  300. fi
  301. # end of 'README'
  302. fi
  303. if test -f 'fromwho.c' -a "${1}" != "-c" ; then 
  304.   echo shar: Will not clobber existing file \"'fromwho.c'\"
  305. else
  306. echo shar: Extracting \"'fromwho.c'\" \(7101 characters\)
  307. sed "s/^X//" >'fromwho.c' <<'END_OF_FILE'
  308. X/*
  309. X  fromwho -- 'from' with extras
  310. X
  311. X  This is a new 'from' program.  Instead of just listing who your mail is
  312. X  from, it tells you how many total messages, how many are new, and
  313. X  for each person you have mail from, tells how many messages they sent,
  314. X  how many are new, and lists the subjects of the messages.
  315. X
  316. X  This code is public domain.  I might keep updating it, or I might forget
  317. X  about it ]:)  But feel free to mail comments / suggestions to me at
  318. X    jearls@data.acs.calpoly.edu
  319. X
  320. X  Usage:
  321. X    fromwho [-l] [-s] [-n] [-f [<mailbox>]]
  322. X
  323. X    -l  Turns listing of users/subjects off.
  324. X    -s  Turns listing of subjects off.
  325. X    -f  Sets the mailbox to read from.
  326. X    -n  List only new mail
  327. X
  328. X  REVISION INFORMATION
  329. X
  330. X  $Revision: 1.3 $
  331. X
  332. X    $Author: jearls $
  333. X      $Date: 91/12/03 11:14:33 $
  334. X
  335. X  Modification Log:
  336. X
  337. X  $Log:    fromwho.c,v $
  338. X    Revision 1.3  91/12/03  11:14:33  jearls
  339. X    PATCH3: Added `-v' option to display the version number.
  340. X    
  341. X    Revision 1.2  91/11/23  12:49:37  jearls
  342. X    PATCH2: Fixed miscellanous bugs, added '-n' option to
  343. X    PATCH2: list only new mail.
  344. X    
  345. X    Revision 1.1  91/10/19  17:05:17  jearls
  346. X    PATCH1: Added support for AIX and other systems that don't
  347. X    PATCH1: use a mail spool.
  348. X    
  349. X    Revision 1.0  91/10/19  14:40:24  jearls
  350. X    Initial revision
  351. X    
  352. X*/
  353. X
  354. X#include <stdio.h>
  355. X#include <pwd.h>
  356. X#include <utmp.h>
  357. X#include <strings.h>
  358. X
  359. X#include "patchlevel.h"
  360. X
  361. X#ifndef MAILDIR
  362. X#define MAILDIR "/usr/spool/mail/"
  363. X#endif  MAILDIR
  364. X
  365. Xtypedef struct {
  366. X  int msgs; int new;
  367. X} mailinfo;
  368. X
  369. Xtypedef struct subjnode {
  370. X  char *subj;
  371. X  int new;
  372. X  struct subjnode *next;
  373. X} subjnode;
  374. X
  375. Xtypedef struct userinfo {
  376. X  char *name;
  377. X  mailinfo info;
  378. X
  379. X  subjnode *subjs, *lastsub;
  380. X
  381. X  struct userinfo *next;
  382. X} userinfo;
  383. X
  384. Xchar *strdup(char *p)
  385. X{
  386. X  char *s = (char *)malloc(1+strlen(p));
  387. X  if (s)
  388. X    (void)strcpy(s, p);
  389. X  return(s);
  390. X}
  391. X
  392. Xchar *strdup2(char *p, char *q)
  393. X{
  394. X  char *s = (char *)malloc(1+strlen(p)+strlen(q));
  395. X  if (s)
  396. X    (void)strcat(strcpy(s, p), q);
  397. X  return(s);
  398. X}
  399. X
  400. X/* translate MAILFILE into a real path */
  401. Xchar *translate(char *mf, char *n, char *h)
  402. X{
  403. X  int len;
  404. X  char *s, *p, *q;
  405. X
  406. X  len = strlen(mf);
  407. X  if (*mf == '~')
  408. X    len += strlen(h) - 1;
  409. X  p = mf;
  410. X  while (p = index(p, '*')) {
  411. X    p++;
  412. X    len += strlen(n)-1;
  413. X  }
  414. X  if (s = (char *)malloc(len+1)) {
  415. X    p = s;
  416. X    if (*mf == '~') {
  417. X      while (*h)
  418. X    *(p++) = *(h++);
  419. X      mf++;
  420. X    } else
  421. X      p = s;
  422. X    while (*mf)
  423. X      if ((*p = *(mf++)) == '*') {
  424. X    q = n;
  425. X    while (*q)
  426. X      *(p++) = *(q++);
  427. X      } else
  428. X        p++;
  429. X    *p = '\0';
  430. X  }
  431. X  return(s);
  432. X}
  433. X
  434. Xmailinfo mailstats(FILE *f, userinfo **ui)
  435. X{
  436. X  mailinfo *mp, mi;
  437. X  char buf[1024];
  438. X  int stat, lp;
  439. X  userinfo *p, *b, *n;
  440. X
  441. X  mi.msgs = mi.new = 0;
  442. X
  443. X  stat = 0;
  444. X  while (fgets(buf, 1024, f)) {
  445. X    if ((!stat) && (!strncmp(buf, "From ", 5))) {
  446. X      for (lp=0; buf[lp+5] != ' '; lp++)
  447. X        buf[lp] = buf[lp+5];
  448. X      buf[lp] = '\0';
  449. X      stat = 1;
  450. X      mi.msgs++;
  451. X      p = *ui; b = (userinfo *)NULL;
  452. X      while (p && (strcmp(buf, p->name) > 0))
  453. X        p = (b=p)->next;
  454. X      if (!p || (strcmp(buf, p->name))) {
  455. X        n = (userinfo *)malloc(sizeof(userinfo));
  456. X        n->name = strdup(buf);
  457. X        n->info.msgs = n->info.new = 0;
  458. X        n->subjs = n->lastsub = (subjnode *)NULL;
  459. X        n->next = p;
  460. X        if (b)
  461. X          b->next = n;
  462. X        else
  463. X          *ui = n;
  464. X        p = n;
  465. X      }
  466. X      mp = &(p->info);
  467. X      mp->msgs++;
  468. X      if (p->lastsub)
  469. X        p->lastsub = (p->lastsub->next = (subjnode *)malloc(sizeof(subjnode)));
  470. X      else
  471. X        p->subjs = p->lastsub = (subjnode *)malloc(sizeof(subjnode));
  472. X      p->lastsub->subj = (char *)NULL;
  473. X      p->lastsub->new = 0;
  474. X      p->lastsub->next = (subjnode *)NULL;
  475. X    }
  476. X    if ((stat) && (!strncmp(buf, "Subject:", 8)))
  477. X      if (!p->lastsub->subj) {
  478. X        buf[strlen(buf)-1] = '\0';
  479. X        p->lastsub->subj = strdup(buf+9);
  480. X      }
  481. X    if ((stat) && (!strncmp(buf, "Status:", 7))) {
  482. X      stat++;
  483. X    }
  484. X    if ((stat) && (*buf == '\n')) {
  485. X      if (stat == 1) {
  486. X        mi.new++;
  487. X        mp->new++;
  488. X        p->lastsub->new = 1;
  489. X      }
  490. X      stat = 0;
  491. X    }
  492. X  }
  493. X
  494. X  return(mi);
  495. X}
  496. X
  497. Xvoid usage(char *name)
  498. X{
  499. X  fprintf(stderr, "usage: %s [-l] [-s] [-n] [-f [<filename>]]\n", name);
  500. X  exit(-1);
  501. X}
  502. X
  503. Xint main(int argc, char **argv)
  504. X{
  505. X  mailinfo mi;
  506. X  userinfo *ui = (userinfo *)NULL, *p;
  507. X  char *mbox, *prog, myname[9], *home;
  508. X  extern char *getenv(char *);
  509. X  int flag, listflag = 1, subjflag = 1, newflag = 0;
  510. X  int lp;
  511. X  FILE *f;
  512. X  subjnode *sp, *tp;
  513. X
  514. X  extern int errno;
  515. X
  516. X/* get user name and home directory */
  517. X  f=(FILE *)fopen("/etc/utmp", "r");
  518. X  if (f==(FILE *)NULL) {
  519. X    perror("Can't open /etc/utmp");
  520. X    exit(1);
  521. X  }
  522. X  fseek(f, 8+sizeof(struct utmp)*ttyslot(), 0);
  523. X  myname[8]='\0';
  524. X  if (fread(myname, 8, 1, f) < 8) {
  525. X    if (!(home = getenv("USER")))
  526. X      if (!(home = getenv("USERNAME")))
  527. X        if (!(home = getenv("LOGNAME"))) {
  528. X          fprintf(stderr, "%s: Who are you?\n", *argv);
  529. X          exit(1);
  530. X        }
  531. X    (void)strcpy(myname, home);
  532. X  }
  533. X  fclose(f);
  534. X
  535. X  if (getpwnam(myname))
  536. X    home = strdup(getpwnam(myname)->pw_dir);
  537. X  else
  538. X    fprintf(stderr, "%s: Who are you?\n", *argv);
  539. X
  540. X#ifdef MAILFILE
  541. X  mbox = translate(MAILFILE, myname, home);
  542. X#else
  543. X  mbox = strdup2(MAILDIR, myname);
  544. X#endif
  545. X
  546. X/* parse arguments */
  547. X  prog = *argv;
  548. X  while ((--argc) && (**(++argv) == '-')) {
  549. X    switch(*(*argv+1)) {
  550. X      case 'f' :  (void)free(mbox);
  551. X                  if (--argc)
  552. X                    mbox = strdup(*(++argv));
  553. X                  else {
  554. X                   mbox = strdup2(home, "/mbox");
  555. X                   argc++;
  556. X                  }
  557. X                  break;
  558. X      case 's' :  subjflag = 0;
  559. X                  break;
  560. X      case 'l' :  listflag = 0;
  561. X                  break;
  562. X      case 'n' :  newflag = 1;
  563. X          break;
  564. X      case 'v' :  puts("fromwho, by johnson earls.  $Revision: 1.3 $");
  565. X          exit(0);
  566. X      default :   free(home);
  567. X                  free(mbox);
  568. X                  usage(prog);
  569. X    }
  570. X  }
  571. X
  572. X/* open the file */
  573. X  f = (FILE *)fopen(mbox, "r");
  574. X  if (f == (FILE *)NULL) {
  575. X    perror(mbox);
  576. X    free(home);
  577. X    free(mbox);
  578. X    exit(errno);
  579. X  }
  580. X
  581. X/* get the info */
  582. X  mi = mailstats(f, &ui);
  583. X
  584. X  (void)fclose(f);
  585. X
  586. X/* print everything out */
  587. X  if (newflag)
  588. X    printf("%s contains %d new messages.\n", mbox, mi.new);
  589. X  else
  590. X    printf("%s contains %d messages, %d new.\n", mbox, mi.msgs, mi.new);
  591. X  while (ui) {
  592. X    if (listflag && (!newflag || ui->info.new))
  593. X      if (newflag)
  594. X        printf("  %-36s:  %d new messages.\n", ui->name, ui->info.new);
  595. X      else
  596. X        printf("  %-36s:  %d messages, %d new.\n", ui->name, ui->info.msgs, ui->info.new);
  597. X    for (sp = ui->subjs; sp; ) {
  598. X      if (sp->subj) {
  599. X        if (listflag && subjflag)
  600. X      if (sp->new || !newflag)
  601. X            printf("    %c %s\n", (sp->new ? '>' : ' '), sp->subj);
  602. X        free(sp->subj);
  603. X      } else
  604. X        if (listflag && subjflag)
  605. X      if (sp->new || !newflag)
  606. X            printf("    %c <none>\n", (sp->new ? '>' : ' '));
  607. X      sp = (tp=sp) -> next;
  608. X      free(tp);
  609. X    }
  610. X    ui = (p=ui)->next;
  611. X    free(p->name);
  612. X    free(p);
  613. X  }
  614. X
  615. X  free(home);
  616. X  free(mbox);
  617. X
  618. X  exit(0);
  619. X}
  620. END_OF_FILE
  621. if test 7101 -ne `wc -c <'fromwho.c'`; then
  622.     echo shar: \"'fromwho.c'\" unpacked with wrong size!
  623. fi
  624. # end of 'fromwho.c'
  625. fi
  626. if test -f 'fromwho.man' -a "${1}" != "-c" ; then 
  627.   echo shar: Will not clobber existing file \"'fromwho.man'\"
  628. else
  629. echo shar: Extracting \"'fromwho.man'\" \(1212 characters\)
  630. sed "s/^X//" >'fromwho.man' <<'END_OF_FILE'
  631. X.\"    @(#)fromwho.%S%    %V%    created by:    Johnson Earls    %D%
  632. X.\"
  633. X.TH FROMWHO %S% "%D%"
  634. X.SH NAME
  635. X.B fromwho
  636. X.RB [ \-l ]
  637. X.RB [ \-s ]
  638. X.RB [ \-n ]
  639. X.RB [ \-f
  640. X.RI [ mailbox ]]
  641. X.SH DESCRIPTION
  642. X.LP
  643. X.B Fromwho
  644. Xis a new
  645. X.RB ` from '
  646. Xutility that lists the contents of a mailbox arranged by the sender.
  647. XFor the mailbox and for each user,
  648. X.B fromwho
  649. Xreports the number of messages in the mailbox or from that user, and
  650. Xhow many of the messages are new.  For each user,
  651. X.B fromwho
  652. Xthen lists the subjects of each message from that user, putting a
  653. X.B >
  654. Xbefore the messages that are new.
  655. X.SH OPTIONS
  656. X.TP
  657. X.B -l
  658. XTurns listing of users/subjects off.
  659. X.TP
  660. X.B -s
  661. XTurns listing of subjects off.
  662. X.TP
  663. X.B -n
  664. XList only new mail
  665. X.TP
  666. X.BI -f " " \fR[ mailbox \fR]
  667. XSets the mailbox to read from.  If
  668. X.I mailbox
  669. Xis not specified then reads from the
  670. X.B mbox
  671. Xfile in your home directory.
  672. X.SH VERSION
  673. XThis describes
  674. X.B fromwho
  675. Xversion %V%.  To find out what version you are running,
  676. Xtype
  677. X.B fromwho
  678. X.BR \-v .
  679. X.SH FILES
  680. X.PD 0
  681. X.TP 20
  682. X.RI /usr/spool/mail/ username
  683. X.TP
  684. X.RI /usr/mail/ username
  685. X.TP
  686. X$HOME/.newmail
  687. XOne of these should be your incoming mail spool.
  688. X.TP
  689. X$HOME/mbox
  690. XThe default mailbox for
  691. X.BR \-f .
  692. X.B 
  693. X.SH SEE ALSO
  694. X.BR from (1)
  695. X\    
  696. X.BR mail (1)
  697. END_OF_FILE
  698. if test 1212 -ne `wc -c <'fromwho.man'`; then
  699.     echo shar: \"'fromwho.man'\" unpacked with wrong size!
  700. fi
  701. # end of 'fromwho.man'
  702. fi
  703. if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  704.   echo shar: Will not clobber existing file \"'patchlevel.h'\"
  705. else
  706. echo shar: Extracting \"'patchlevel.h'\" \(595 characters\)
  707. sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
  708. X/*
  709. X  fromwho patchlevel
  710. X
  711. X  This includes the RCS log and the patchlevel define
  712. X
  713. X  $Log:    patchlevel.h,v $
  714. X    Revision 1.3  91/12/03  11:14:15  jearls
  715. X    PATCH3: Added `-v' option to display the version number.
  716. X    
  717. X    Revision 1.2  91/11/23  12:49:40  jearls
  718. X    PATCH2: Fixed miscellanous bugs, added '-n' option to
  719. X    PATCH2: list only new mail.
  720. X    
  721. X    Revision 1.1  91/10/19  17:06:12  jearls
  722. X    PATCH1: Added support for AIX and other systems that don't
  723. X    PATCH1: use a mail spool.
  724. X    
  725. X    Revision 1.0  91/10/19  14:40:25  jearls
  726. X    Initial revision
  727. X    
  728. X*/
  729. X
  730. X#define PATCHLEVEL 3
  731. END_OF_FILE
  732. if test 595 -ne `wc -c <'patchlevel.h'`; then
  733.     echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  734. fi
  735. # end of 'patchlevel.h'
  736. fi
  737. echo shar: End of archive 1 \(of 1\).
  738. cp /dev/null ark1isdone
  739. MISSING=""
  740. for I in 1 ; do
  741.     if test ! -f ark${I}isdone ; then
  742.     MISSING="${MISSING} ${I}"
  743.     fi
  744. done
  745. if test "${MISSING}" = "" ; then
  746.     echo You have the archive.
  747.     rm -f ark[1-9]isdone
  748. else
  749.     echo You still need to unpack the following archives:
  750.     echo "        " ${MISSING}
  751. fi
  752. ##  End of shell archive.
  753. exit 0
  754.